#include <iostream>
using namespace std;

#include <queue>

//priority_queue 最大值优先级队列 最小值优先级队列

void test1()
{
        //最大值优先级队列
        priority_queue<int> p1; //默认情况下最大值优先级队列
        priority_queue<int, vector<int>, less<int>> p2; //提前定义好的函数
        
        p1.push(33);
        p1.push(11);
        p1.push(55); //虽然元素55相较于其他元素是后入队列,但是55是最先出队列的
        p1.push(22);
        cout<<"队头元素: " << p1.top()<<endl;
        cout<<"队列的大小: "<<p1.size()<<endl;

        while (p1.size() > 0)
        {
                cout<<p1.top()<<" ";
                p1.pop();
        }
        cout<<endl;
        
        cout<<"测试最小值优先级队列"<<endl;

        //最小值优先级队列
        priority_queue<int, vector<int>, greater<int>> p3; 
        p3.push(33);
        p3.push(11);
        p3.push(55); 
        p3.push(22);
        cout<<"队头元素: " << p3.top()<<endl;
        cout<<"队列的大小: "<<p3.size()<<endl;
        while (p3.size() > 0)
        {
                cout<<p3.top()<<" ";
                p3.pop();
        }
        cout<<endl;
}

int main(int argc, char const *argv[])
{
        test1();
        return 0;
}
